package icom.acm.action;

import icom.acm.manager.T_UserMgr;
import icom.acm.util.locker.Password;

public class UserSafeAction extends Action{
	private String uid;
	private String oldpwd;
	private String pwd;
	private String newpwd;
	private String newpwdconfim;
	private String token;
	public String pwdModif(){
		// 防止重复提交
		String token = (String)session.getAttribute("token");
		if (token==null){
			return "ERROR";
		} else if (!token.equals(this.token)){
			return "ERROR";
		}
		session.removeAttribute("token");
		// 旧密码错，或新密码不一样
		String temp = Password.MD5(pwd);
		if(!oldpwd.equals(temp) || !newpwd.equals(newpwdconfim))
		{
			return "ERROR";
		}
		T_UserMgr um = new T_UserMgr();
		um.setPwd(uid, Password.MD5(newpwd));
		return "SUCCESS";
	}
	
	public String getUid() {
		return uid;
	}
	public void setUid(String uid) {
		this.uid = uid;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public String getNewpwd() {
		return newpwd;
	}
	public void setNewpwd(String newpwd) {
		this.newpwd = newpwd;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getNewpwdconfim() {
		return newpwdconfim;
	}

	public void setNewpwdconfim(String newpwdconfim) {
		this.newpwdconfim = newpwdconfim;
	}

	public String getOldpwd() {
		return oldpwd;
	}

	public void setOldpwd(String oldpwd) {
		this.oldpwd = oldpwd;
	}
}
